package com.neusoft.work.service.impl;

import java.util.concurrent.TimeUnit;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import com.neusoft.work.service.RedisService;

@Service
@Repository
public class RedisServiceImpl implements RedisService{
	
	@Autowired
	private RedisTemplate redisTemplate;
	
	@Override
	public void set(String key, String value) {
		// TODO Auto-generated method stub
		ValueOperations vo=redisTemplate.opsForValue();
		vo.set(key, value);
	}

	@Override
	public String get(String key) {
		// TODO Auto-generated method stub
		ValueOperations vo=redisTemplate.opsForValue();
		String val=(String) vo.get(key);
		return val;
	}

	@Override
	public void set(String key, String value, long time, TimeUnit unit) {
		// TODO Auto-generated method stub
		ValueOperations vo=redisTemplate.opsForValue();
//		调用带过期时间的存储方法
		vo.set(key, value, time, unit);
	}
	
}
